package edu.ccut.saturn.studio.naviagtor.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.navigator.CommonViewer;

import edu.ccut.saturn.studio.naviagtor.SaturnLabelProvider;

/**
 * 实现文件名称和Xml文件内部的name标签名切换。
 * 
 * @author alf 2008-7-16
 */
public class ChangeNameAction implements IViewActionDelegate {

	public void init(IViewPart view) {
	}

	public void run(IAction action) {
		CommonViewer commonViewer = SaturnLabelProvider.getProjectExplorerView();
		commonViewer.getControl().setRedraw(false);
		Object[] expandedElements = commonViewer.getExpandedElements();
		SaturnLabelProvider.getInstance().changeName();
		commonViewer.refresh();
		commonViewer.setExpandedElements(expandedElements);
		commonViewer.getControl().setRedraw(true);
	}

	public void selectionChanged(IAction action, ISelection selection) {
	}
}
